import networkx as nx
import matplotlib.pyplot as plt
import xlrd


topology_data_path = r'../result/topology.xlsx'
def graph(data):
    G = nx.Graph(data)
    nx.draw_networkx(G)
    plt.show()

def getData(data_path):
    excel_data = xlrd.open_workbook(data_path)
    table = excel_data.sheets()[0]
    rows = table.nrows
    data=[]

    for i in range(1, rows-1):
        antecedent = table.cell(i,0).value
        consequent = table.cell(i,1).value
        if antecedent is "企业服务总线":
           data.append((antecedent, consequent))
    return data

graph(getData(topology_data_path))
